<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta charset="utf-8">
		<title>{:C('defaultinfo.name')} - Powered By {:L('AUTHOR')}</title>
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">		
		<meta name="description" content=""/>
		<meta name="author" content="{:L('AUTHOR')}"/>
		<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;" name="viewport" />		
		<link type="text/css" href="__PUBLIC__/css/app.css" rel="stylesheet" />
		<link rel="shortcut icon" href="__PUBLIC__/ico/favicon.png"/>
		<script src="__PUBLIC__/js/jquery-1.9.0.min.js" type="text/javascript"></script>	
		<script type="text/javascript" src="__PUBLIC__/js/zh_CN.js"></script>
		<script src="__PUBLIC__/js/PCASClass.js" type="text/javascript"></script>
		<script type="text/javascript" src="__PUBLIC__/js/formValidator-4.0.1.min.js" charset="UTF-8"></script>
		<script src="__PUBLIC__/js/jquery-ui-1.10.0.custom.min.js" type="text/javascript"></script>
		<script src="__PUBLIC__/js/WdatePicker.js" type="text/javascript"></script>
		<style>
			select, input[type="text"], input[type="password"], input[type="datetime"], input[type="datetime-local"], input[type="date"], input[type="month"], input[type="time"], input[type="week"], input[type="number"], input[type="email"], input[type="url"], input[type="search"], input[type="tel"], input[type="color"], .uneditable-input {height:45px;}
			#owner_role_id{width:130px;}
		</style>
	</head>
	<body>	
		<iframe id="customer" name="customer" src="{:U('Business/ajax')}" style="display:none;width:100%;"></iframe>
		<script>
			$("#customer").height($(window).height());
		</script>
		<iframe id="contacts" name="contacts" src="{:U('Contacts/radiolistdialogs')}" style="display:none;width:100%;">		
		</iframe>
		<script>
			$("#contacts").height($(window).height());	
		</script>
		<div id="crmcontent">
			<form id="form1" action="{:U(Business/add)}" method="post">
				<table class="table">
					<div style="width:100%;float:left;">
						<div class="title_a" style="float:left;"><p>基本信息</p></div>
						<div class="trborder">
							<div class="tdleft">负责人</div>
							<div class="tdright">
								{$owner_name}
							</div>
						</div>
						<volist name="field_list['main']" id="vo"> 
							<div class="trborder">
								<div class="tdleft">{$vo.name}</div>
								<div class="<if condition="$vo.form_type eq 'box'">tdright<else />tdright tdrightt</if>">{$vo.html}</div>
							</div>                        
						</volist>
						<volist name="field_list['data']" id="vo"> 
							<div class="trborder">
								<div class="tdleft">{$vo.name}</div>
								<div class="<if condition="$vo.form_type eq 'box'">tdright<else />tdright tdrightt</if>">{$vo.html}</div>
							</div>                        
						</volist>
						<div class="tfoot">
							<div class="tfoot_a">
								<input class="btn btn-primary" name="submit" id="submit" type="submit" value="保存"/>
							</div>
						</div>
					</div>
				</table>
			</form>
		</div>
<script>
$(function(){		
	$('#customer_name').click(
		function(){
			$(".css").attr('href','/Public/css/docs1.css');			
			$("#crmcontent").hide();					
			$("#customer").show();
			parent.customer.pullDownAction()
		}
	);
	
	$('#contacts_name').click(
		function(){
			var customer_name = $("#customer_name").val();				
			if(customer_name == null || customer_name == 'null' || customer_name == 'undefined' || customer_name == ''){
				alert('请先选择客户！');
				return false;
			}else{
				$(".css").attr('href','/Public/css/docs1.css');			
				$("#crmcontent").hide();					
				$("#contacts").show();	
				parent.contacts.pullDownAction();				
			}			
		}
	);
	
	
})
$(function(){
    $.formValidator.initConfig({formID:"form1",debug:false,submitOnce:true,
        onError:function(msg,obj,errorlist){
			alert(msg);
		},
		submitAfterAjaxPrompt : '{:L('THERE_ARE_DATA_ARE_ASYNCHRONOUS_VALIDATION')}'});
	<volist name="field_list[main]" id="vo">
		<if condition="$vo['is_validate'] == 1">
			<if condition="$vo['form_type'] != 'box' || $vo['setting']['type'] == 'select'">
				$("#{$vo[field]}").formValidator({
					tipID:"{$vo[field]}Tip",
					<if condition="$vo['is_null'] == 1">
					onShow:"<span style='color:red;'>*必填项</span>",
					empty:false,
					<else />
					onShow:" ",
					empty:true,
					</if>
					onFocus:" ",
					onCorrect:"<span style='color:green;'>√</span>"
				}).inputValidator({
					<if condition="$vo['is_null'] == 1">
					min:1,max:{$vo[max_length]|default="255"},
					onshow:"{:L('NOT NULL',array($vo[name]))}",
					<else />
					min:0,max:{$vo[max_length]|default="255"},
					</if>
					onErrorMin:"{:L('NOT NULL',array($vo[name]))}",
					onErrorMax:"{:L('MAXIMUM_REQUEST_LENGTH_EXCEEDED',array($vo[name]))}"
				 });
				<if condition="$vo['form_type'] == 'email'">
				$("#{$vo[field]}").regexValidator({
					regExp:"email",
					dataType:"enum",
					onError:"{:L('A_OLUTE_OR_SELF_RELATIVE',array($vo[name]))}"
				});
				<elseif condition="$vo['form_type'] == 'mobile'"/>
				 $("#{$vo[field]}").regexValidator({
					regExp:"mobile",
					dataType:"enum",
					onError:"{:L('A_OLUTE_OR_SELF_RELATIVE',array($vo[name]))}"
				});
				<elseif condition="$vo['form_type'] == 'phone'"/>
				 $("#{$vo[field]}").regexValidator({
					regExp:"tel",
					dataType:"enum",
					onError:"{:L('A_OLUTE_OR_SELF_RELATIVE',array($vo[name]))}"
				});
				<elseif condition="$vo['form_type'] == 'datetime'"/>
				 $("#{$vo[field]}").regexValidator({
					regExp:"date",
					dataType:"enum",
					onError:"{:L('A_OLUTE_OR_SELF_RELATIVE',array($vo[name]))}"
				});
				<elseif condition="$vo['form_type'] == 'number'"/>
				 $("#{$vo[field]}").regexValidator({
					regExp:"num",
					dataType:"enum",
					onError:"{:L('A_OLUTE_OR_SELF_RELATIVE',array($vo[name]))}"
				});
				 </if>
				 <if condition="$vo['is_unique'] == 1 && $vo['field']!='name'">
				$("#{$vo[field]}").ajaxValidator({
					dataType : "json",
					type : "GET",
					async : true,
					isValid : true,
					url : "{:U('business/validate')}",
					success : function(data){
						if( data.status == 1 ) return false;
						if( data.status == 0 ) return true;
						return false;
					},
					error: function(jqXHR, textStatus, errorThrown){alert("{:L('THE_SERVER_DID_NOT_RETURN_DATA_MAY_BE_THE_SERVER_BUSY_PLEASE_TRY_AGAIN')}"+errorThrown);},
					onError : "{:L('THIS_DISABLED_PLEASE_CHANGE',array($vo[name],$vo[name]))}",
					onWait : "{:L('LEGITIMACY_CHECKING_PLEASE_WAIT',array($vo[name]))}"; 
				 </if>
			 <else />
				 <if condition="$vo['setting']['type'] == 'checkbox'">
				 $(":checkbox[name='{$vo['field']}[]']").formValidator({
					 tipID:"{$vo[field]}Tip",
					 <if condition="$vo['is_null'] == 1">
					 onShow:"<span style='color:red;'>{:L('WILL_OPTIONS')}</span>",
					 <else />
					 onShow:" ",
					 </if>
					 onFocus:" ",
					 onCorrect:"<span style='color:green;'>√</span>"
				 }).inputValidator({
					<if condition="$vo['is_null'] == 1">
					 min:1,
					 <else/>
					 min:0,
					 </if>
					onError:"{:L('PLEASE_SELECT',array($vo[name]))}"
				 });
				 <elseif condition="$vo['setting']['type'] == 'select'"/>
					 $("#{$vo[field]}").formValidator({
						 tipID:"{$vo[field]}Tip",
						 <if condition="$vo['is_null'] == 1">
						 onShow:"<span style='color:red;'>{:L('WILL_OPTIONS')}</span>",
						 <else />
						 onShow:" ",
						 </if>
						 onFocus:" ",
						 onCorrect:"<span style='color:green;'>√</span>"
					 }).inputValidator({
						<if condition="$vo['is_null'] == 1">
						 min:1,
						 <else/>
						 min:0,
						 </if>
						onError:"{:L('PLEASE_SELECT',array($vo[name]))}"
					 });
				 <else />
					 $(":radio[name='{$vo['field']}']").formValidator({
						 tipID:"{$vo[field]}Tip",
						 <if condition="$vo['is_null'] == 1">
						 onShow:"<span style='color:red;'>{:L('WILL_OPTIONS')}</span>",
						 <else />
						 onShow:" ",
						 </if>
						 onFocus:" ",
						 onCorrect:"<span style='color:green;'>√</span>"
					 }).inputValidator({
						<if condition="$vo['is_null'] == 1">
						 min:1,
						 <else/>
						 min:0,
						 </if>
						onError:"{:L('PLEASE_SELECT',array($vo[name]))}"
					 });
				</if>
			 </if>
		 </if>
	</volist>
	<volist name="field_list[data]" id="vo">
		<if condition="$vo['is_validate'] == 1">
			<if condition="$vo['form_type'] != 'box' || $vo['setting']['type'] == 'select'">
				$("#{$vo[field]}").formValidator({
					tipID:"{$vo[field]}Tip",
					<if condition="$vo['is_null'] == 1">
					onShow:"<span style='color:red;'>*必填项</span>",
					empty:false,
					<else />
					onShow:" ",
					empty:true,
					</if>
					onFocus:" ",
					onCorrect:"<span style='color:green;'>√</span>"
				}).inputValidator({
					<if condition="$vo['is_null'] == 1">
					min:1,max:{$vo[max_length]|default="255"},
					onshow:"{:L('NOT NULL',array($vo[name]))}",
					<else />
					min:0,max:{$vo[max_length]|default="255"},
					</if>
					onErrorMin:"{:L('NOT NULL',array($vo[name]))}",
					onErrorMax:"{:L('MAXIMUM_REQUEST_LENGTH_EXCEEDED',array($vo[name]))}"
				 });
				<if condition="$vo['form_type'] == 'email'">
				$("#{$vo[field]}").regexValidator({
					regExp:"email",
					dataType:"enum",
					onError:"{:L('A_OLUTE_OR_SELF_RELATIVE',array($vo[name]))}"
				});
				<elseif condition="$vo['form_type'] == 'mobile'"/>
				 $("#{$vo[field]}").regexValidator({
					regExp:"mobile",
					dataType:"enum",
					onError:"{:L('A_OLUTE_OR_SELF_RELATIVE',array($vo[name]))}"
				});
				<elseif condition="$vo['form_type'] == 'phone'"/>
				 $("#{$vo[field]}").regexValidator({
					regExp:"tel",
					dataType:"enum",
					onError:"{:L('A_OLUTE_OR_SELF_RELATIVE',array($vo[name]))}"
				});
				<elseif condition="$vo['form_type'] == 'datetime'"/>
				 $("#{$vo[field]}").regexValidator({
					regExp:"date",
					dataType:"enum",
					onError:"{:L('A_OLUTE_OR_SELF_RELATIVE',array($vo[name]))}"
				});
				<elseif condition="$vo['form_type'] == 'number'"/>
				 $("#{$vo[field]}").regexValidator({
					regExp:"num",
					dataType:"enum",
					onError:"{:L('A_OLUTE_OR_SELF_RELATIVE',array($vo[name]))}"
				});
				 </if>
				 <if condition="$vo['is_unique'] == 1 && $vo['field']!='name'">
				$("#{$vo[field]}").ajaxValidator({
					dataType : "json",
					type : "GET",
					async : true,
					isValid : true,
					url : "{:U('business/validate')}",
					success : function(data){
						if( data.status == 1 ) return false;
						if( data.status == 0 ) return true;
						return false;
					},
					error: function(jqXHR, textStatus, errorThrown){alert("{:L('THE_SERVER_DID_NOT_RETURN_DATA_MAY_BE_THE_SERVER_BUSY_PLEASE_TRY_AGAIN')}"+errorThrown);},
					onError : "{:L('THIS_DISABLED_PLEASE_CHANGE',array($vo[name],$vo[name]))}",
					onWait : "{:L('LEGITIMACY_CHECKING_PLEASE_WAIT',array($vo[name]))}"; 
				 </if>
			 <else />
				 <if condition="$vo['setting']['type'] == 'checkbox'">
				 $(":checkbox[name='{$vo['field']}[]']").formValidator({
					 tipID:"{$vo[field]}Tip",
					 <if condition="$vo['is_null'] == 1">
					 onShow:"<span style='color:red;'>{:L('WILL_OPTIONS')}</span>",
					 <else />
					 onShow:" ",
					 </if>
					 onFocus:" ",
					 onCorrect:"<span style='color:green;'>√</span>"
				 }).inputValidator({
					<if condition="$vo['is_null'] == 1">
					 min:1,
					 <else/>
					 min:0,
					 </if>
					onError:"{:L('PLEASE_SELECT',array($vo[name]))}"
				 });
				 <elseif condition="$vo['setting']['type'] == 'select'"/>
					 $("#{$vo[field]}").formValidator({
						 tipID:"{$vo[field]}Tip",
						 <if condition="$vo['is_null'] == 1">
						 onShow:"<span style='color:red;'>{:L('WILL_OPTIONS')}</span>",
						 <else />
						 onShow:" ",
						 </if>
						 onFocus:" ",
						 onCorrect:"<span style='color:green;'>√</span>"
					 }).inputValidator({
						<if condition="$vo['is_null'] == 1">
						 min:1,
						 <else/>
						 min:0,
						 </if>
						onError:"{:L('PLEASE_SELECT',array($vo[name]))}"
					 });
				 <else />
					 $(":radio[name='{$vo['field']}']").formValidator({
						 tipID:"{$vo[field]}Tip",
						 <if condition="$vo['is_null'] == 1">
						 onShow:"<span style='color:red;'>{:L('WILL_OPTIONS')}</span>",
						 <else />
						 onShow:" ",
						 </if>
						 onFocus:" ",
						 onCorrect:"<span style='color:green;'>√</span>"
					 }).inputValidator({
						<if condition="$vo['is_null'] == 1">
						 min:1,
						 <else/>
						 min:0,
						 </if>
						onError:"{:L('PLEASE_SELECT',array($vo[name]))}"
					 });
				</if>
			 </if>
		 </if>
	</volist>
});
</script>
	</body>
</html>